package com.septagon.wildtunnel;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.septagon.wildtunnel.model.GetThreadListTask;
import com.septagon.wildtunnel.model.HttpClient;
import com.septagon.wildtunnel.R.id;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.view.*;

public class ThreadListActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_thread_list);
		
		ListView lv = (ListView)this.findViewById(id.listView1);
		
		ArrayAdapter<String> aa = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1);
		
		Intent it = this.getIntent();
		String title = it.getStringExtra("Name");
		this.setTitle(title);
		
		String url = it.getStringExtra("Url");
		GetThreadListTask gtlt = new GetThreadListTask(aa,lv);
		gtlt.execute(url);
		
		lv.setOnItemClickListener(new OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ListView listView = (ListView) parent;
                String item = (String) listView.getItemAtPosition(position);
                com.septagon.wildtunnel.model.Thread th = ((List<com.septagon.wildtunnel.model.Thread>)listView.getTag()).get(position);
                String url = th.getUrl();
                
            }
		});
		
	}
}
